package StudyCode.summary.zipfile;

import java.io.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class WriteByteArrayToFileUsingBufferedOutputStream {
	public static void main(String[] args) {

		String strFileName = "Demo.txt";
		BufferedOutputStream bos = null;

		try {
			FileOutputStream fos = new FileOutputStream(new File(strFileName));
			bos = new BufferedOutputStream(fos);

			String str = "Example";
			System.out.println("BufferedOutputStream: 正在将字节数组写入文件");
			bos.write(str.getBytes());
			System.out.println("BufferedOutputStream : 字节数组写入文件完毕");
		} catch (FileNotFoundException fnfe) {
			fnfe.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		} finally {
			if (bos != null) {
				try {

					bos.flush();

					bos.close();

				} catch (Exception e) {
				}
			}
		}

	}
}
